<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="vue.js"></script>
    <style>
        .activated {
            color: red
        }
    </style>
</head>

<body>
    <div id="app">
        <!-- class的对象绑定，通过isActivated控制activted样式是否显示 -->
        <div @click="handleDivClick" :class="{activated :isActivated}">helloworld</div>
    </div>

    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                isActivated: false
            },
            methods: {
                handleDivClick: function () {
                    this.isActivated = !this.isActivated
                }
            }
        })
    </script>
</body>

</html>